#include<unistd.h>
#include<stdlib.h>
#include<stdio.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<fcntl.h>

int main(int argc,char **argv){

    char tmpname[L_tmpnam];
    char *filename;
    FILE *tmpfp;

   
    if((filename = tmpnam(tmpname)) != NULL)    //方式一:不推荐使用
    {
        char tmpname[L_tmpnam];
        char *filename;
        FILE *fp;
        strcpy(tmpname,"/tmp/dfXXXXXX");//file name:df...
        filename=mktemp(tmpname);//generate tempfile
        printf("temporary file name:%s\n",filename);
        
        fp=tmpfile();
        if (fp) printf("temporary file oepn.\n");
        else perror("error");
        while(1);
        exit(0);  
    }
   



   return 0;
}